<?php

namespace app\api\controller\points;
use app\common\service\Result;
use app\api\model\user\PointsLog as PointsLogModel;

/**
 * 积分明细控制器
 */
class Log
{
    /**
     * 积分明细列表
     */
    public function index()
    {
        $user_id = request()->user_id;
        $limit = 20;
        $type = input('type', '');
        $where = [];
        if ($type == 'plus') {
            $where[] = ['value', '>', 0];
        } elseif ($type == 'minus') {
            $where[] = ['value', '<', 0];
        }
        $lists = (new PointsLogModel)->getList($user_id, $limit, $where);
        return Result::success($lists);
    }

}